<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input id="inputBox" />
    <script>
       let inputBox = document.getElementById('inputBox');
       inputBox.addEventListener('keyup',(event)=>{
          let searchText = inputBox.value;
          console.log(`开始使用关键字${searchText}去查找搜索结果`);
       });
        //声明一个变量，表示开始时间
      /*  let startTime;
       document.addEventListener('keydown',(event)=>{
        console.log('keydown');
        if(event.key === 'a' && !startTime){
            startTime=new Date().getTime();
            console.log(startTime);
        }
       });
       document.addEventListener('keyup',(event)=>{
        if(event.key === 'a'){
            //得到松开a键的时间
            let currentTime =new Date().getTime();
            console.log(currentTime);
            //相减得到就是按下按钮持续的时间
            const duration = currentTime-startTime;
            console.log(`按下a键持续了${duration/1000}秒`);
        }
       }); */

    </script>
</body>
</html>